//
//  CYSecurityCell.m
//  CaiYun
//
//  Created by 今日信息科技 on 2017/7/5.
//  Copyright © 2017年 今日信息科技. All rights reserved.
//

#import "CYSecurityCell.h"
@interface CYSecurityCell()
@property (nonatomic, strong) CYLabel *titleLBL;
@property (nonatomic, strong) CYView *line;
@end
@implementation CYSecurityCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.line.hidden = NO;
    }
    return self;
}
- (CYLabel *)titleLBL{
    if (!_titleLBL) {
        _titleLBL = [[CYLabel alloc]initWithText:nil size:AL(PT(28)) textcolor:ColorHex(0x88888)];
        [self addSubview:_titleLBL];
        
        WS(self)
        [_titleLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf).with.offset(AL(PT(37)));
            make.centerY.equalTo(weakSelf);
            make.size.mas_equalTo(_titleLBL.bounds.size);
        }];
    }
    return _titleLBL;
}

- (CYView *)line{
    if (!_line) {
        _line = [[CYView alloc]initWithColor:[UIColor lightGrayColor]];
        [self addSubview:_line];
        
        WS(self)
        [_line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(weakSelf.mas_bottom).with.offset(0);
            make.centerX.equalTo(weakSelf);
            make.size.mas_equalTo(CGSizeMake(weakSelf.bounds.size.width - AL(PT(37 * 2)), 0.5));
        }];
    }
    return _line;
}
- (void)setTitle:(NSString *)title{
    if (_title != title) {
        _title = title;
        self.titleLBL.text = title;
        [self updateSubLayout];
    }
}

- (void)updateSubLayout{
    
    [_titleLBL mas_updateConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(_titleLBL.bounds.size);
    }];
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
